CHANGE: @W-19419849@: Adding option to generate the violations only for the changed files - #110
CHANGE: @W-19419849@: Adding option to generate the violations only for the changed files#110namrata111f wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
…ut example script)
There was a problem hiding this comment.
| let violations: Violation[] | ||
|
|
||
| // Use all violations | ||
| violations = results.getViolationsSortedBySeverity() |
There was a problem hiding this comment.
@namrata111f : Can we move this to the else block of if (changedFiles && changedFiles.length > 0) { ?
| ).length | ||
|
|
||
| const summaryBody = MESSAGE_FCNS.REVIEW_BODY( | ||
| results.getTotalViolationCount(), |
There was a problem hiding this comment.
@namrata111f : Shouldn't it show the filtered count ?
| ` num-sev3-violations: ${results.getSev3ViolationCount()}\n` + | ||
| ` num-sev4-violations: ${results.getSev4ViolationCount()}\n` + | ||
| ` num-sev5-violations: ${results.getSev5ViolationCount()}` | ||
| `Parsed results from ${jsonOutputFile}: found ${results.getTotalViolationCount()} total violations across all files` |
There was a problem hiding this comment.
@namrata111f : If changedFilesOnly is true then we should only show the filtered count . Right ?
| const sev2Count = violationsToShow.filter(v => v.getSeverity() === 2).length | ||
| const sev3Count = violationsToShow.filter(v => v.getSeverity() === 3).length | ||
| const sev4Count = violationsToShow.filter(v => v.getSeverity() === 4).length | ||
| const sev5Count = violationsToShow.filter(v => v.getSeverity() === 5).length |
There was a problem hiding this comment.
nvm , It's good to optimize this mutiple iterations .
`// Calculate counts for the violations we're showing (single pass)
let totalCount = 0
let sev1Count = 0
let sev2Count = 0
let sev3Count = 0
let sev4Count = 0
let sev5Count = 0
for (const violation of violationsToShow) {
totalCount++
const severity = violation.getSeverity()
if (severity === 1) sev1Count++
else if (severity === 2) sev2Count++
else if (severity === 3) sev3Count++
else if (severity === 4) sev4Count++
else if (severity === 5) sev5Count++
}`
|
Discussed with team and we need to just add the output variables here. |
Adding option to generate the violations only for the changed files. We have added new param: changed-files-only which controls if only the files with changes would be considered when reporting the violation counts.
Testing:
Screen.Recording.2025-12-02.at.1.12.12.PM.mov